// Copyright (C) 2025, ZWSOFT Co., LTD.(Guangzhou)
// Licensed under the MIT License. See LICENSE in the project root for license information.

namespace TestClient.Domain;

/// <summary>
/// Represents the complete schema and data for a single database.
/// This is the top-level object for defining a test database.
/// </summary>
public class DatabaseDefinition
{
    public List<TableDefinition> Tables { get; set; } = [];
}

/// <summary>
/// Represents a single table's schema and its initial data.
/// </summary>
public class TableDefinition
{
    /// <summary>
    /// The name of the table (e.g., "Users").
    /// </summary>
    public required string Name { get; set; }

    /// <summary>
    /// A list of column definitions that make up this table's schema.
    /// </summary>
    public List<ColumnDefinition> Columns { get; set; } = [];

    /// <summary>
    /// The data to be inserted into the table. Each dictionary represents one row,
    /// mapping column names (string) to their values (object).
    /// </summary>
    public List<Dictionary<string, object>> Rows { get; set; } = [];
}

/// <summary>
/// Represents a single column within a table.
/// </summary>
public class ColumnDefinition
{
    /// <summary>
    /// The name of the column (e.g., "Id", "FirstName").
    /// </summary>
    public required string Name { get; set; }

    /// <summary>
    /// The SQLite data type (e.g., "INTEGER", "TEXT", "REAL", "BLOB").
    /// </summary>
    public required string DataType { get; set; }

    /// <summary>
    /// If true, adds the "PRIMARY KEY" constraint to this column.
    /// </summary>
    public bool IsPrimaryKey { get; set; } = false;

    /// <summary>
    /// If true, adds the "NOT NULL" constraint to this column.
    /// </summary>
    public bool IsNotNull { get; set; } = false;

    /// <summary>
    /// The default value for the column. The generator will format it
    /// correctly in the SQL statement (e.g., strings will be quoted).
    /// </summary>
    public object? DefaultValue { get; set; } = null;
}